Repository navigation
feat(epic-web): leave invoices paid after the cutover to Course Builder - #1920
Merged
Merged
Conversation
Both this app and the Course Builder app fulfil a paid one-off Epic Web invoice, and both Stripe endpoints stay live through the migration, so each invoice would be fulfilled twice. Invoices are created by hand and carry no app marker. Ownership is split by when the invoice was paid, against one cutoff both apps read from EPIC_WEB_INVOICE_CUTOVER_AT (ISO-8601 UTC, trailing Z). With the variable set, an invoice paid at or after it is ignored here (owned-by-course-builder). Unset keeps today's behaviour. A malformed value, or a paid invoice with no paid_at, fails the run instead of picking a side. Inert until the variable is set. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
stripe-invoice-paidnow decides, right after re-fetching the invoice and before reading the catalog or writing anything, whether this app owns it:EPIC_WEB_INVOICE_CUTOVER_ATunset → unchanged behaviour: every paid one-off Epic Web invoice is fulfilled here.YYYY-MM-DDTHH:MM[:SS[.mmm]]Z, e.g.2026-12-08T15:05:00Z, the same format Course Builder accepts) and the invoice'sstatus_transitions.paid_atis at or after it → returns{kind: 'ignore', reason: 'owned-by-course-builder', paidAt, cutoverAt}; Course Builder fulfils it.+00:00, and impossible dates such as2026-02-30) → the run fails loudly (retriable, so a fix is picked up); it never silently picks a side.paid_at→ the run fails without retry; we don't guess.PaidInvoiceSchemanow parsesstatus_transitions.paid_at.Why
During the Epic Web move to Course Builder both apps receive
invoice.paid/invoice.payment_succeededfrom the same Stripe account, and team invoices are created by hand in the dashboard, so there is no origin marker to split on (unlike checkout sessions, see #1919). With both handlers live, every invoice would be fulfilled twice: two purchases, twice the seats, two welcome emails.The split is by when the invoice was paid, against one cutoff both apps carry in the same variable.
paid_atis set once and never changes, and both handlers decide on the re-fetched invoice, so each invoice has exactly one owner regardless of deploy order, retries or redeliveries. Course Builder's half (ignore when the variable is unset orpaid_at< cutoff) lands separately.Safety
Tests
lib/invoice-fulfilment.test.ts: 32 new cases (boundaries, millisecond cutoff, the accepted forms and 15 rejected ones, mirroring Course Builder's parser tests so both apps accept exactly the same strings, 4 missing-paid_atshapes, unpaid invoice, schema).inngest/functions/stripe/invoice-paid.test.ts: 5 handler cases. An ignored invoice runs onlyload invoice+decide owner, with no catalog read and no write or event; before the cutoff and unset still fulfil; misconfiguration fails without reading or writing.jest(epic-web): 63/63.tsc --noEmit: clean.Not for merge without review; the cutoff value is chosen separately.
The Course Builder half is on badass-courses/course-builder branch
creeland/epw-invoice-cutoff-on-1199(a patch on top of course-builder#1199).🤖 Generated with Claude Code